/**
 * 
 */
define(
		[ 'platform.common', 'bootbox', 'gridview', 'formview', 'barview' ],
		function(platform) {

			return {
				loadTreeNodes : function() {
					var result = platform
							.servicebreak('~/rest/pubcode/selectAll').responseText;
					if (result == null || result == '')
						return '';
					var nodes = JSON2.parse(result);
					return nodes;
				},
				save : function(param) {
					platform.servicebreakAsync('~/rest/pubcode/save', param,
							'post', function() {
								platform.showOperTip('DEALING');
							}).done(function() {
						platform.showOperTip('SAVESUC');
						var gridview = require('gridview');
						var formview = require('formview');
						var barview = require('barview');
						gridview.refresh();
						// 是否继续添加
						var bootbox = require('bootbox');
						bootbox.confirm({
							title : '继续新增提示',
							size : 'small',
							message : '是否继续新增该节点下数据?',
							buttons : {
								confirm : {
									label : '继续',
									className : 'btn-success btn-sm'
								},
								cancel : {
									label : '取消',
									className : 'btn-default btn-sm'
								}
							},
							callback : function(result) {
								if (result) {
									formview.code_id(platform.uuid());
									formview.code_value('');
									formview.code_text('');
								} else {
									barview.fnCloseDlg();
								}
							}
						});
						//								platform.confirm('继续新增提示', 'small',
						//										'是否继续新增该节点下数据', '继续', '取消', function() {
						//											formview.code_id(platform.uuid());
						//											formview.code_value('');
						//											formview.code_text('');
						//										}, function() {
						//											barview.fnclosedlg();
						//										});
					});
				},
				del : function(id) {
					var param = {};
					param.code_id = id;
					platform.servicebreakAsync('~/rest/pubcode/delete', param,
							'post', function() {
								platform.showOperTip('DEALING');
							}).done(function(response) {
						if (response.success) {
							var gridview = require('gridview');
							platform.showOperTip('DELSUC');
							gridview.refresh();

                        } else {
							platform.showErrorTip(response.msg);

                        }
					});
				}
			}
		});